package com.linktrip.devicemanager.task;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
import com.linktrip.devicemanager.entity.Upgrade;
import com.linktrip.devicemanager.server.UpgradeService;
import com.linktrip.devicemanager.util.SpringContextUtil;

/**
 * @author : CaineZhu E-mail:CaineZhu@me.com
 * @version : V1.0
 * @创建时间 ： 2017年5月27日 上午11:55:45
 * @类说明 : blablabla
 */
public class UpgradeInfoTask implements Callable<Upgrade> {

	UpgradeService service = SpringContextUtil.getBean("upgradeService");
	private int deviceId;
	private int swVersion;
	private int hwVersion;

	public UpgradeInfoTask(int deviceId, int swVersion, int hwVersion) {
		this.deviceId = deviceId;
		this.swVersion = swVersion;
		this.hwVersion = hwVersion;
	}

	@Override
	public Upgrade call() throws Exception {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("swVersion", swVersion);
		map.put("swHwVersion", hwVersion);
		map.put("deviceId", deviceId);
		List<Upgrade> list = service.getList(map);
		Upgrade up = list.size() > 0 ? list.get(0) : null;
		return up;
	}

}
